package com.nuit.cxl.ch2.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

//@Controller
//restful
//ctrl + F5
@RestController
@RequestMapping("/system")
public class SystemInfoController {

    @Operation(summary = "Get a system by id", description = "Returns a system detail")
    @ApiResponses(value = {
            @ApiResponse(responseCode = "200", description = "成功返回"),
            @ApiResponse(responseCode = "404", description = "找不到哦")
    })
    @RequestMapping("/info/{id}")
//    @ResponseBody
    public String getSystemInfo(@PathVariable int id) {
        return "systemInfo" + id;
    }

    @RequestMapping("/info-error")
//    @ResponseBody
    public String getInfoWithError() {
        return "{\"appName\": \"后台管理系统\"}";
    }

    /**
     * 重定向到 Spring Boot 官方文档
     * 访问路径: /system/docs
     */
    @RequestMapping("/docs")
    public String redirectToDocs() {
        // 关键: 返回值以 "redirect:" 开头
        return "redirect:https://spring.io/projects/spring-boot";
    }
}
